/********************************************************************************
 *      Copyright:  (C) 2022 xiezongyi<1764417007@qq.com>
 *                  All rights reserved.
 *
 *       Filename:  client.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(12/08/22)
 *         Author:  xiezongyi <1764417007@qq.com>
 *      ChangeLog:  1, Release initial version on "01/08/22 18:08:49"
 *                 
 ********************************************************************************/
#ifndef _CLIENT_H_
#define _CLIENT_H_

/*  sample data  */
struct sample_data
{
    char    datatime[32];
    char    ID[32];
    float   temp;

};

/* sample send data */
typedef struct sample_send_s
{
    int                 fd;
    int                 second;
    sqlite3             *db;
    tlv_buf_t           tlv;
    struct sample_data  data;
    struct event        *event;
    struct bufferevent  *bev;

}sample_send_t;

/*  Gets the socket status at this point  */
int get_tcp_info(int sockfd);

/*  callback: event write  */
void get_msg_cb(int fd, short events, void *arg);

/*  callback: buffervent's write  */
void write_cb(struct bufferevent *bev, void *arg);

/*  callback: bufferevent's event  */
void event_cb(struct bufferevent *bev, short events, void *arg);

/*  callback: event's timeout  */
void timeout_cb(evutil_socket_t fd, short what, void *arg);

/*  signal register function  */
void signal_handler(int signum);

/*  print the help information  */
void print_usage(char *progname);

/*  pack sample data  */
int get_sample_data(struct sample_data *sample, char *s_buf);

#endif
